package com.example.springmysqldemo.controller;

import com.example.springmysqldemo.entity.User;
import com.example.springmysqldemo.result.ResultUsers;
import com.example.springmysqldemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
@CrossOrigin
public class AdminController {
    @Autowired
    UserService userService;

    @RequestMapping("/adminlist")
    public ResultUsers admins(){
        List<User> users = userService.findAllUsers();
        return new ResultUsers(200,"获取管理员列表成功",users);
    }
}
